package com.isunland.managesystem.adapter;

import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.QualityInspetion;
import com.isunland.managesystem.ui.ExtraDownLoadDialogFragment;
import com.isunland.managesystem.utils.MyStringUtil;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/7 16:28
 */
public class QualityInspetionAdapter extends SimpleButterKnifeAdapterAdapter<QualityInspetion>
    implements View.OnClickListener {
  //默认构造方法
  public QualityInspetionAdapter(BaseVolleyActivity context, ArrayList<QualityInspetion> objects) {
    super(context, objects);
  }

  //自定义vieew,默认3,4,5view隐藏.
  //可设置view样式,
  @Override protected void customizeView(TextView tvNameSearchPerson,
      TextView tvDepartmentSearchPerson, TextView tvThree, TextView tvFour, TextView tvFive,
      TextView tvSix, Button btn) {
    super.customizeView(tvNameSearchPerson, tvDepartmentSearchPerson, tvThree, tvFour, tvFive,
        tvSix, btn);
    tvThree.setVisibility(View.VISIBLE);
    tvFour.setVisibility(View.VISIBLE);
    tvFive.setVisibility(View.VISIBLE);

    //noinspection deprecation
    tvNameSearchPerson.setTextColor(context.getResources().getColor(R.color.blue_click));
    tvNameSearchPerson.setOnClickListener(this);
  }

  @Override protected void setText1(TextView tvOne, QualityInspetion item) {
    tvOne.setText(MyStringUtil.connect(context.getString(R.string.docBlob), item.getDocBlob()));
  }

  @Override protected void setText2(TextView tvTwo, QualityInspetion item) {
    tvTwo.setText(MyStringUtil.connect(context.getString(R.string.customerEvaluation),
        context.getString(R.string.colon), item.getCustomerEvaluation()));
  }

  @Override protected void setText3(TextView tvThree, QualityInspetion item) {
    tvThree.setText(MyStringUtil.connect(context.getString(R.string.levelQualityInspetion),
        context.getString(R.string.colon), item.getLevel()));
  }

  @Override protected void setText4(TextView tvFour, QualityInspetion item) {
    tvFour.setText(MyStringUtil.connect(context.getString(R.string.checkDate),
        context.getString(R.string.colon), item.getCheckDate()));
  }

  @Override protected void setText5(TextView tvFive, QualityInspetion item) {
    tvFive.setText(MyStringUtil.connect(context.getString(R.string.checkStaffNameQualityInspetion),
        context.getString(R.string.colon), item.getCheckStaffName()));
  }

  @Override public void onClick(View view) {
    if (view == null || view.getTag() == null) return;
    QualityInspetion item = (QualityInspetion) view.getTag();
    if (item == null || TextUtils.isEmpty(item.getDocPath())) return;
    ExtraDownLoadDialogFragment dialog =
        ExtraDownLoadDialogFragment.newInstance("", item.getDocPath());
    FragmentManager fm = context.getSupportFragmentManager();
    dialog.show(fm, "");
  }
}
